package com.dm.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author DongJunJun
 * @Date 2022/9/6 18:28
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    //状态
    private String success;
    //状态码
    private String errorCode;
    //返回的消息
    private String msg;
    //返回的数据
    private T data;

    /**
     * 只返回消息和状态码
     *
     * @param success
     * @param errorCode
     */
    public Result(String success, String errorCode) {
        this.success = success;
        this.errorCode = errorCode;
    }

    /**
     * 返回带有消息提示的数据
     *
     * @param success
     * @param errorCode
     * @param msg
     */
    public Result(String success, String errorCode, String msg) {
        this.success = success;
        this.errorCode = errorCode;
        this.msg = msg;
    }

    /**
     * 返回带有数据的响应
     *
     * @param success
     * @param errorCode
     * @param data
     */
    public Result(String success, String errorCode, T data) {
        this.success = success;
        this.errorCode = errorCode;
        this.data = data;
    }
}
